#ifndef SEARCH_MANAGER_H
#define SEARCH_MANAGER_H

#include <string>
#include <vector>
#include "inverted_index.h"
#include "index_manager.h"
#include "doc_manager.h"

class Token;
class Result;

class SearchManager {
public:
    SearchManager(std::string indexDB, std::string docDB);
    ~SearchManager();

    int Search(std::string query);
    int LoadDB();

private:
    void Display(std::vector<Result> &result);
    int SearchDocs(std::vector<Token> &tokens, std::string &query, std::vector<Result> &result);
    double CalcScore(std::vector<Token> &tokens);
    int SearchPhrase(std::vector<Token> &tokens, int docID);
    std::vector<Token> Split(std::string &str);

private:
    IndexManager indexMgr_;
    DocManager docManager_;
    std::string indexDBPath_;
    std::string docDBPath_;
};

#endif
